# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=unicode-character-database
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=15.1.0
pkgrel=1
pkgdesc="Unicode Character Database (mingw-w64)"
arch=(any)
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
license=(BSD)
url="https://www.unicode.org/"
source=("UCD-${pkgver}.zip::https://www.unicode.org/Public/zipped/${pkgver}/UCD.zip"
        "Unihan-${pkgver}.zip::https://www.unicode.org/Public/zipped/${pkgver}/Unihan.zip"
        'LICENSE::https://www.unicode.org/license.txt')
noextract=({UCD,Unihan}-$pkgver.zip)
sha512sums=('6285b78d5765092d04632f2bdf23f43fe4c3d8acc28700ff941b5a647bf86aba348ea280cee54f5761e534070439cd5628cb25cb7cd9d7dca08e05000f434f54'
            'fc1a32fc68b3e1d2d358fca91c2cd6c1103557405e91ff558585f18a2e9b1ee6f8af89e7ee922ff36cade67a5cf4f5b4042ba97d350af7b92b18f161eef5ec78'
            '1fc045470e5d44e57c5de2ba1e6b1c323a6a350612149a0ded3e99893eb751e5d0b3385b571cd9bf8f370debfaff284262f30a790a0c39d8adfe93bb2b0ebd6d')

package() {
  for _f in UCD Unihan; do
    install -Dm644 ${_f}-${pkgver}.zip "${pkgdir}${MINGW_PREFIX}/share/unicode/${_f}.zip"
    bsdtar -C "${pkgdir}${MINGW_PREFIX}/share/unicode" -x --no-same-owner --no-same-permissions -f $_f-$pkgver.zip
  done

  #  ln -s unicode "$pkgdir${MINGW_PREFIX}/share/${_realname}"
  # FS#49938: A bunch of compatibility symlinks
  mkdir -p "${pkgdir}"${MINGW_PREFIX}/share/unicode/ucd
  cp -r * "${pkgdir}${MINGW_PREFIX}/share/unicode/ucd/"
  for _f in ${_realname} unicode-data unidata; do
    cp -r "${pkgdir}"${MINGW_PREFIX}/share/unicode "${pkgdir}${MINGW_PREFIX}/share/${_f}/"
  done

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
